$(function () {
    $.hidePreloader();
    var message = $("#message").val();
    if(message !=null && $.trim(message) !=''){
        $.alert(message,function () {
            window.location.href = baseloaction+ '/mobile/user/login';
        });
    }
    $("body").on('click','#doLogin',function () {
        var account = $("#account").val();
        var password = $("#password").val();
        if(password !=null && $.trim(password)!=''){
            var encrypt = new JSEncrypt();
            encrypt.setPublicKey(publicKey);
            password= encrypt.encrypt(password);
        }
        $.ajax({
            url:baseloaction + '/mobile/user/doLogin',
            type:'post',
            dataType:'json',
            data:{
                'loginAccount':account,
                'password':password,
                'sign':sign
            },
            success:function (result) {
                if(result.success==true){
                    var url = result.url;
                    if(url==null || $.trim(url)==''){
                        redirectURL(baseloaction +'/mobile/uc/index');
                    }else{
                        window.location.href = baseloaction + url;
                    }
                }else{
                    sign = result.keyMap.sign;
                    publicKey = result.keyMap.publicKey;
                    $.toast(result.message);
                }
            },
            error:function (error) {
                $.toast('系统错误，登录失败');
            }
        });
    }).on('click','#qqLogin',function () {//QQ登录
        window.location.href = baseloaction + '/mobile/thirdLogin/authLogin?appType=QQ';
    }).on('click','#weixinLogin',function () {//微信登录
        $.showPreloader("登录中...");
        window.location.href = baseloaction + '/mobile/thirdLogin/authLogin?appType=WEIXIN';
        setTimeout(function () {
            $.hidePreloader();
        },1000);
    });
});